/**
 * echarts图表通用
 */
import { ref } from 'vue';
export default function () {
  const chart = ref<any>();

  const chartResizeHandler = () => {
    if (chart.value) {
      chart.value.resize();
    }
  };
  const mounted = () => {
    window.addEventListener('resize', chartResizeHandler, { passive: true });
  };

  const beforeDestroy = () => {
    window.removeEventListener('resize', chartResizeHandler);
  };

  return {
    chart,
    mounted,
    beforeDestroy
  };
}
